package com.twu.biblioteca;

import java.io.IOException;
import java.util.Scanner;
import static java.lang.System.*;

public class BibliotecaApp {

    public static void main(String[] args) throws IOException{

       out.println(WelcomeMessage());

        Library library=new Library();
        Scanner input = new Scanner(System.in);

        String proceed="n";
        String library_number;
        String password;
        String bookname;

       do

       {
           out.println("Main Menu\n 1. list books 2. Checkout books 3.Return Books 4.List Movies 5.Checkout movies");

           out.println("Enter ur choice");

           char choice= (char) in.read();


           switch (choice) {
               case '1':
                   library.displayBook();


                   break;
               case '2':
                   System.out.println("Enter login details");
                   System.out.println("Enter the library number");
                   library_number=input.next();
                   System.out.println("Enter the password");
                   password =input.next();
                   if(library.userAthentication(library_number,password))
                   {
                   out.println("Enter the book name to be checkedout");

                   bookname = input.next();
                   library.checkOutBooks(bookname);
                   }
                   break;

               case '3':
                   System.out.println("Enter login details");
                   System.out.println("Enter the library number");
                    library_number=input.next();
                   System.out.println("Enter the password");
                    password=input.next();
                   if(library.userAthentication(library_number,password))
                   {
                   out.println("Enter the book name to be returned");
                   bookname = input.next();
                   library.BookReturn(bookname);
                   }
                   break;

               case '4':
                   library.displayMoive();
                   break;

               case '5':
                   System.out.println("Enter the movie name to be checked out");
                   String moviename=input.next();
                   library.checkOutMovies(moviename);
                   break;


               default:
                   out.println("Select a valid option!");

           }
           System.out.println("Do u want to continue(y/n?");
           proceed= input.next();

       } while ( proceed.equals("y"));

    }

    public static String WelcomeMessage() {

        return "welcome";
    }

}
